﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GcmpModelInterface.h"
#include "IElement.h"

namespace gcmp
{
    class IDocument;
    class IExternalDatas;
    class IViewRange;
    class IPolygon;
    
    /// \brief 平面区域。针对主视图可以局部调整视图范围
    class GCMP_MODEL_INTERFACE_EXPORT IPlanRegion : public IElement
    {
        DEFINE_CAST_DERIVED(gcmp::IPlanRegion, gcmp::IElement)
    public:

        /// \brief 创建平面区域
        ///
        /// \param[in] pDocument 文档指针
        /// \param[in] modelViewId 平面区域所在视图的ElementId
        /// \param[in] opPolygon 平面区域轮廓，轮廓信息目前只支持一个环，环需要封闭，新增的轮廓不能与已有平面区域重叠
        /// \return 如果成功，则返回平面区域的指针，如果失败，则为nullptr
        static IPlanRegion* Create(IDocument *pDocument, const ElementId& modelViewId, OwnerPtr<IPolygon> opPolygon);

        /// \brief 设置平面区域轮廓
        ///
        /// \param[in] opPolygon 平面区域轮廓，不能为空,不能与其他平面区域重叠
        /// \return 如果成功，则返回true，如果失败，返回false
        virtual bool SetBoundary(OwnerPtr<IPolygon> opPolygon) = 0;
        
        /// \brief 获取平面区域轮廓
        ///
        /// \return 平面区域轮廓
        virtual const IPolygon* GetBoundary() const = 0;

        /// \brief 获取平面区域视图范围
        ///
        /// \return 平面区域的视图范围
        virtual IViewRange* GetViewRange() = 0;

        /// \brief 获取平面区域视图范围
        ///
        /// \return 平面区域的视图范围
        virtual const IViewRange* GetViewRange() const = 0;

        /// \brief 获取所属视图的ElementId
        ///
        /// \return 所属视图的ElementId
        virtual ElementId GetModelViewId() const = 0;

        /// \brief 获取平面区域轮廓变化RdId
        /// \return 平面区域轮廓变化RdId
        virtual RegenDataId GetBoundaryChangedRdId() const = 0;

        /// \brief 获取Implementation Uid
        ///
        /// \return UniIdentity 返回ImplementationUid
        static UniIdentity GetImplementationUid();

        /// \brief 通过ElementId返回IPlanRegion指针
        ///
        /// \return IPlanRegion指针
        static IPlanRegion* GetPlanRegion(const IDocument* pDoc, const ElementId& elementIdViewRegion);

        /// \brief 返回平台默认的平面区域的拷贝组件
        ///
        /// 相对IElementCopyPasteComponent::CreateCopyWithExternalDataCopyPasteComponent创建的组件会重写UpdateAfterCopy
        /// 会把拷贝的平面区域的跟新到对应视图
        ///
        /// \return IElementCopyPasteComponent指针
        static OwnerPtr<IElementCopyPasteComponent> CreatePlanRegionCopyPasteComponent();

        /// \brief 析构函数
        virtual ~IPlanRegion();
    };
}
